//
// Created by Semir on 2020/4/23.
//

#include <iostream>
#include <string>
#include <map>

using namespace std;

string pins;
string words;
string str;
map<char, char> table;
int count[26];

int main() {
    cin >> pins;
    cin >> words;
    cin >> str;
    string res = "";
    bool exception = false;
    for (int i = 0; i < pins.length(); i++) {
        if (table.count(pins[i]) != 0) {
            if (table[pins[i]] != words[i]) {
                exception = true;
                break;
            }
        } else {
            table[pins[i]] = words[i];
            count[words[i] - 'A']++;
        }
    }
    if (!exception) {
        for (int i = 0; i < 26; i++) {
            if (table.count('A' + i) == 0 || count[i] > 1) {
                exception = true;
                break;
            }
        }
    }
    if (exception) {
        cout << "Failed";
    } else {
        for (int i = 0; i < str.length(); i++) {
            res += table[str[i]];
        }
        cout << res;
    }
    return 0;
}
